Fix GitHub Pages Mermaid diagram rendering in docs/#4
Merged
Basic-Nature merged 2 commits intomainfrom Nov 28, 2025
Merged
Conversation
Co-authored-by: Basic-Nature <50002689+Basic-Nature@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix mermaid diagram rendering in docs site
Fix GitHub Pages Mermaid diagram rendering in docs/
Nov 28, 2025
Owner
|
@copilot Can you please keep going with making sure the mermaid graphs work on the automated generated files. I would really appreciate if we get more of the graphs to show the node connection for pipeline_map and project_audit. The automated script for these exist within the shared_logic so if we need to make sure the mermaid syntax is correc to regenerate than we should work on patching the code there rather than those specific md. the todos.md, project_audit, and the pipeline_map are all automated scripts to keep track of the overall architecture of the file. There was also some slight automated script in the architecture.md so these are prone to have problems if the code generating the files is not fixed. |
Copilot stopped work on behalf of
Basic-Nature due to an error
November 28, 2025 03:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After script-regenerated
docs/*.mdfiles, mermaid diagrams stopped rendering due to missing YAML front matter and improper Mermaid initialization.Changes
YAML Front Matter
pipeline_map.mdandproject_audit.md(the only files with mermaid blocks that were missing it)Layout Updates (
_layouts/default.html)deferto all script tagsmermaid-init.jsNew
assets/js/mermaid-init.js<pre><code class="language-mermaid">→<div class="mermaid">Refactored
assets/js/custom.jsOriginal prompt
Summary:
The docs/ folder is used to deploy the project site via GitHub Pages. After a script regenerated docs/*.md files, mermaid diagrams stopped rendering and some pages appear unprocessed. Root causes likely include missing YAML front matter in regenerated Markdown files, missing/incorrect docs/_layouts/default.html that loads assets, asset path mismatches due to missing site.baseurl usage, and lack of a mermaid initialization script that converts fenced mermaid code blocks to .mermaid divs and calls mermaid.init().
Goal:
Create a PR that restores proper GitHub Pages rendering for docs/ mermaid diagrams and ensures the static site builds correctly when docs/*.md are re-generated by scripts. The PR should add or update files in the docs/ tree and update content while preserving existing page content.
Deliverables (actions for the coding agent):
layout: default
title: "REPLACE_WITH_PAGE_TITLE"
(Replace the title with a one-line title derived from the file name; keep the rest of the file unchanged.)
Provide a safe, minimal layout that will not overwrite custom head blocks if they already exist (i.e., keep markup simple but workable).
Use the following implementation (agent should create file with this content):
(function(){
function migrateMermaidCodeBlocks(){
try{
var codes = document.querySelectorAll('pre > code.language-mermaid, pre > code.lang-mermaid');
codes.forEach(function(code){
var pre = code.parentNode;
var container = document.createElement('div');
container.className = 'mermaid';
container.textContent = code.textContent;
pre.parentNode.replaceChild(container, pre);
});
if(window.mermaid && typeof window.mermaid.init === 'function'){
window.mermaid.initialize({ startOnLoad: false });
window.mermaid.init(undefined, document.querySelectorAll('.mermaid'));
}
}catch(e){
console.warn('mermaid-init error', e);
}
}
if(document.readyState === 'loading') document.addEventListener('DOMContentLoaded', migrateMermaidCodeBlocks);
else migrateMermaidCodeBlocks();
})();
url: "https://basic-nature.github.io"
baseurl: "/html_Parser_prototype"
If docs/_config.yml already contains these keys, do not overwrite other configs; only set/add these two keys if missing or wrong.
Update any layouts or include files to reference scripts/styles using relative_url or prepend {{ site.baseurl }} to absolute assets. Specifically, change script/link tags to use the Liquid filters like: {{ '/assets/js/mermaid-init.js' | relative_url }}. Do not hardcode absolute paths beginning with '/'.
Add a short README note docs/README_pages_FIX.md describing what changed and why (front matter, baseurl, mermaid-init), so future generators preserve front matter and assets.
Tests and verification steps (in PR description):
Implementation notes and constraints for the agent:
This pull request was created as a result of the following prompt from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.